package com.lg.online_shop.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.lg.online_shop.entity.Favorite;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface FavoriteMapper extends BaseMapper<Favorite> {

    // 分页查询收藏夹
    @Select("SELECT * FROM favorite WHERE user_id = #{userId}")
    Page<Favorite> selectFavoriteByUserId(Page<Favorite> page, Integer userId);

//    判断是否已经收藏
    @Select("SELECT * FROM favorite WHERE user_id = #{userId} AND good_id = #{goodId}")
    Favorite selectOne(Favorite favorite);
}
